package com.meihua.baoleyi.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.meihua.baoleyi.R;
import com.meihua.baoleyi.base.BaseMyAdapter;
import com.meihua.baoleyi.ui.AddBankInfoPhoneActivity;
import com.meihua.baoleyi.ui.AddressActivity;
import com.meihua.baoleyi.ui.IdentitySafeActivity;
import com.meihua.baoleyi.utils.MyImageHelperUtil;
import com.meihua.baoleyi.utils.ToastUtil;
import com.meihua.baoleyi.utils.ToastUtils;

import java.util.List;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by liming on 2017/10/16
 */

public class GoodsImageAdapter extends BaseMyAdapter {
    private List<String> list;
    private Context context;

    public GoodsImageAdapter(Context context, List<String> list) {
        super(context);
        this.list = list;
        this.context=context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder vh;
        if (view==null) {
            view = inflater.inflate(R.layout.item_goodsimage_layout, viewGroup, false);
            vh = new ViewHolder(view);
            /*得到各个控件的对象*/
            vh.iv_tupian= (ImageView) view.findViewById(R.id.iv_tupian);
            view.setTag(vh);
        }else{
            vh= (ViewHolder) view.getTag();
        }
        String goodsimageBean = list.get(i);
        MyImageHelperUtil.getMyImageHelper().bindImage(goodsimageBean,vh.iv_tupian);
        return view;
    }
    static class ViewHolder{
        ImageView iv_tupian;
        ViewHolder(View view) {
            ButterKnife.bind(this,view);
        }
    }
    @OnClick({R.id.iv_tupian})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_tupian:
                overlay(IdentitySafeActivity.class);
                break;
        }
    }
}
